@extends('admin.mainlayout')
@section('title')
    <div class="title"><span>意见反馈</span></div>
    <br/>
    <div class="main_top" >
        <form id='search' action="{{urlAdmin('Feedback','getIndex')}}" method="get">
            <span>选择时间段</span>
            <input type="text" name="starttime" class="laydate-icon" id="hello2"/><span>到</span>
            <input type="text" name="endtime" class="laydate-icon" id="hello3"/>
            <input type="text" name="keyword" style="width: 120px;height: 21px;margin-left: 100px" placeholder="序号/用户"/>
            <span id="sousuo" >搜索</span>
        </form>
    </div>
    <style type="text/css">
        #sousuo{
            display:inline-block;
            background: #347c1e;
            text-align: center;
            color:white;
            height:25px;
            width:40px;
            margin-left: 40px;
            cursor: pointer;
        }
        #sousuo:hover{
            background-color: #2d94e8;
        }
    </style>
    @endsection
    @section('content')
            <!-- start 意见反馈-->
    <div class="seven">
        <table>
            <tr>
                <th>序号</th>
                <th>内容</th>
                <th>用户</th>
                <th>时间</th>
                <th>详情</th>
                <th>操作</th>
            </tr>
            @if(!empty($res['data']))
                @foreach($res['data'] as $v)
            <tr>
                <td>{{$v['id']}}</td>
                @if(strlen($v['content'])>24)
                <td>{{mb_substr($v['content'],0,10)}}...</td>
                    @else
                <td>{{$v['content']}}</td>
                @endif

                <td>{{$v['name']}}</td>
                <td>{{$v['created_at']}}</td>
                <td style="cursor: pointer;" onclick="fn('{{$v['content']}}');">查看详情</td>
                <td style="cursor: pointer;color: red;" onclick="del({{$v['id']}});">删除</td>
            </tr>
                @endforeach
            @else
            <tr>
                <td colspan="6">暂无数据...</td>
            </tr>

            @endif

        </table>
        <div class="del">
            <div class="bot">
                @if($res['prev_page_url'])
                    <p class="prev"><a href="{{$res['prev_page_url']}}">上一页</a></p>
                @endif
                <ul>
                    @foreach($res['pageNoList'] as $v)
                        <li @if($res['current_page'] ==  $v )class="active_list" @endif ><a href="/center/feedback?page={{$v}}">{{$v}}</a></li>
                    @endforeach
                </ul>
                @if($res['next_page_url'])
                    <p class="next"><a href="{{$res['next_page_url']}}">下一页</a></p>
                @endif
            </div>
        </div>
    </div>
    <!-- end 意见反馈-->
    <script>

        //删除意见反馈
        function del(id){

            layer.confirm('确定要删除该项吗?',{btn:['确定','取消']},function(){

                layer.closeAll();
                layer.load(2, {shade: false});
                $.ajax({
                    type:'post',
                    url:"{{urlAdmin('Feedback','postDel')}}",
                    data:{'id':id,'_token':'{{csrf_token()}}'},
                    dataType:'json',
                    success: function (res) {
                        layer.closeAll();
                        // alert(res);
                        if(res['status']==1){

                            layer.msg(res.msg,{icon:6});
                            setTimeout("location.reload()",1500);

                        }else{

                            layer.msg(res.msg,{icon:5});

                        }

                    }

                });

            },function(){

                layer.msg('已取消了!');

            });
        }


        window.onload = function(){



            //时间搜索
            var oSousuo = document.getElementById('sousuo');
            var oSearch = document.getElementById('search');

            oSousuo.onclick = function(){
                //加载效果
                layer.load(2, {shade: false});
                oSearch.submit();

            }

            laydate({
                elem: '#hello2'
            });
            laydate({
                elem: '#hello3'
            });

        }

        function fn(a){

            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                content: a
            });

        }

    </script>
@endsection